package com.freeseed.model.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.freeseed.model.entity.UserDtl;
import com.freeseed.model.mapper.UserDtlMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Allwayz
 * @since 2020-03-20
 */
@RestController
@RequestMapping("userDetails")
public class UserDtlController {
    @Autowired
    private UserDtlMapper userDtlMapper;

    @GetMapping
    public List<UserDtl> getUserDtlList(){
        List<UserDtl> userDtlList = userDtlMapper.selectList(new QueryWrapper<>());
        return userDtlList;
    }

    @GetMapping("{Id}")
    public UserDtl getUserDtlById(@PathVariable int Id){
        UserDtl userDtl = userDtlMapper.selectById(Id);
        return userDtl;
    }

    @PutMapping
    public UserDtl updateUserDtl(UserDtl userDtl){
        userDtlMapper.update(userDtl,new UpdateWrapper<UserDtl>().eq("user_dtl_id",userDtl.getUserDtlId()));
        return userDtl;
    }
}
